#include "dma.h"



MX_DMA_Cb_Fun_t mx_dma_cb_dun[MX_DMA_CB_NUM] = {NULL}; 

void MX_DMA_Init(void) 
{
  __HAL_RCC_DMA2_CLK_ENABLE();
  HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);

  /* DMA2_Stream0_IRQn interrupt configuration */
  // HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
  // HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
}


void MX_DMA_Register_IT_Cb(uint8_t id, uint8_t type, MX_DMA_Cb_Fun_t fun)
{
  if(MX_DMA_IS_CB_ID(id))
  {
      switch(type)
      {
        case MX_DMA_CB_TYPE_CPLT:
          mx_dma_cb_dun[id] = fun;
          break;

        default:
          break;
      }
  }
}

void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
{
  extern SPI_HandleTypeDef st7789_hspi;
  if(&st7789_hspi == hspi)
  {
    if(mx_dma_cb_dun[MC_DMA_CB_ID_ST7789])
    {
      mx_dma_cb_dun[MC_DMA_CB_ID_ST7789]();
    }
  }
}
